// ===================================
// <copyright>
// This file is part of LABSMFController.
//
//    LABSMFController is free software: you can redistribute it and/or modify
//    it under the terms of the GNU General Public License as published by
//    the Free Software Foundation, either version 3 of the License, or
//    (at your option) any later version.
//
//    LABSMFController is distributed in the hope that it will be useful,
//    but WITHOUT ANY WARRANTY; without even the implied warranty of
//    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//    GNU General Public License for more details.
//
//    You should have received a copy of the GNU General Public License
//    along with LABSMFController.  If not, see <http://www.gnu.org/licenses/>.
//    Copyright 2011 David Bakker
//
//</copyright>
// <author>David Bakker</author>
// <email>mailto:DavidFBakker@gmail.com</email>
// <created>Saturday, May 07, 2011</created>
// <lastedit>Saturday, May 07, 2011</lastedit>
// ===================================

using System;

namespace LABSMFController.LABS
{
    public static class Util
    {
        public static Guid StringToGuid(string str)
        {
            int i1 = Convert.ToInt32(str.Substring(0, 8), 16);
            var s1 = (short) Convert.ToInt32(str.Substring(9, 4), 16);
            var s2 = (short) Convert.ToInt32(str.Substring(14, 4), 16);
            var b1 = (byte) Convert.ToInt32(str.Substring(19, 2), 16);
            var b2 = (byte) Convert.ToInt32(str.Substring(21, 2), 16);
            var b3 = (byte) Convert.ToInt32(str.Substring(24, 2), 16);
            var b4 = (byte) Convert.ToInt32(str.Substring(26, 2), 16);
            var b5 = (byte) Convert.ToInt32(str.Substring(28, 2), 16);
            var b6 = (byte) Convert.ToInt32(str.Substring(30, 2), 16);
            var b7 = (byte) Convert.ToInt32(str.Substring(32, 2), 16);
            var b8 = (byte) Convert.ToInt32(str.Substring(34, 2), 16);
            var ret = new Guid(i1, s1, s2, b1, b2, b3, b4, b5, b6, b7, b8);
            return ret;
        }
    }
}